package cn.itsource.ymcc.feign.fallback;

import cn.itsource.ymcc.domain.CourseDoc;
import cn.itsource.ymcc.feign.ESCourseFeign;
import cn.itsource.ymcc.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ESCourseFeignFallbackFactory implements FallbackFactory<ESCourseFeign> {
    @Override
    public ESCourseFeign create(Throwable throwable) {
        return new ESCourseFeign() {
            @Override
            public JsonResult save(List<CourseDoc> courseDoc) {
                throwable.printStackTrace();
                return JsonResult.error("保存数据失败");
            }

            @Override
            public JsonResult selectByCourseId(Long courseId) {
                return JsonResult.error("获取数据失败");
            }

            @Override
            public JsonResult selectByCourseIds(List<Long> ids) {
                return JsonResult.error("获取数据失败");
            }
        };
    }
}
